package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;

public class SortInteger {
    public static void main(String[] args) {
        Random r = new Random();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(r.nextInt(100) + 1);
        }
        System.out.println("list:" + list);
        Collections.sort(list);
        System.out.println("排序后的list:" + list);
        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        System.out.println("倒序后的list:" + list);
        Collections.reverse(list);
        System.out.println("再次反转后的list:"+list);
    }
}
